//
//  MapViewController.m
//  ACE
//
//  Created by Mickey Yin on 2021/12/1.
//

#import "MapViewController.h"
#import "YLJCountDownButton.h"
#import "UIButton+CountDown.h"

@interface MapViewController ()
@property (nonatomic, strong) UIButton *tempBtn;
@property (nonatomic, strong) YLJCountDownButton *textBtn;
@end

@implementation MapViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
//    self.view.backgroundColor = UIColor.cyanColor;
    
    self.navigationItem.title = @"地图";
    self.view.backgroundColor= UIColor.whiteColor;
    
    [self setUI];
}

- (void)setUI {
    
    self.tempBtn = [[YLJCountDownButton alloc] initWithFrame:CGRectMake(100, 100, 200, 30)];
    [self.tempBtn setTitle:@"正面" forState:UIControlStateNormal];
    self.tempBtn.tag = 117;
    self.tempBtn.backgroundColor = UIColor.orangeColor;
    [self.view addSubview:self.tempBtn];
    [self.tempBtn addTarget:self action:@selector(textBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.textBtn = [[YLJCountDownButton alloc] initWithFrame:CGRectMake(100, 200, 200, 30)];
    [self.textBtn setTitle:@"反面" forState:UIControlStateNormal];
    self.textBtn.tag = 119;
    self.textBtn.backgroundColor = UIColor.orangeColor;
    [self.view addSubview:self.textBtn];
    [self.textBtn addTarget:self action:@selector(textBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
}

- (void)textBtnAction:(UIButton *)sender {
    
    if (sender.tag == 117) {
        [_tempBtn mcountDownFromTime:10 title:@"重新获取验证码" unitTitle:@"s" mainColor:[UIColor orangeColor] countColor:[UIColor lightGrayColor]];
    }else {
        [_textBtn xcountDownFromTime:15 unitTitle:@"秒后重新获取验证码" completion:^(YLJCountDownButton * _Nonnull countDownButton) {
            
        } ];
        
           
//        [MBProgressHUD showTextInView:self.view text:@"保存失败" animated:YES];
//       [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        //[MBProgressHUD showLoadingInView:self.view text:@"success" animated:YES];
        
        // 第一个参数:延迟的时间
        // 可以通过改变队列来改变线程
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
           // 需要延迟执行的代码
            //[MBProgressHUD hideHudInView:self.view];
            
        });
    }
    
}



@end
